package com.nengjiang.wsplayer.bean;

import com.xuhao.didi.core.iocore.interfaces.IPulseSendable;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.charset.Charset;

/**
 * 心跳请求(okSocket框架用)
 */
public class PulseRequest extends BaseBean implements IPulseSendable {
    public PulseRequest(int msgType) {
        super(msgType);
    }

    public String content;

    @Override
    public byte[] parse() {
        byte[] body = content.getBytes(Charset.defaultCharset());
        ByteBuffer bb = ByteBuffer.allocate(4 + body.length);
        bb.order(ByteOrder.BIG_ENDIAN);
        bb.putInt(body.length);
        bb.put(body);
        return bb.array();
    }

    public static class PulseData {
        public int count;
    }


}
